//
//  SearchDetailViewCell.m
//  GentlemanAnime
//
//  Created by dllo on 15/7/6.
//  Copyright (c) 2015年 lanou3g.com 蓝欧科技. All rights reserved.
//

#import "SearchDetailViewCell.h"

#define WIDTH self.contentView.frame.size.width
#define HEIGHT self.contentView.frame.size.height
#define SWIDTH [UIScreen mainScreen].bounds.size.height

@interface SearchDetailViewCell ()

@property(nonatomic, retain)UIView *backView_;
@property(nonatomic, retain)UILabel *titleLabel_;
@property(nonatomic, retain)UILabel *authorLabel_;
@property(nonatomic, retain)UILabel *zoneLabel_;
@property(nonatomic, retain)UILabel *nameLabel_;

@end

@implementation SearchDetailViewCell

- (void)dealloc {
    [_backView_ release];
    [_titleLabel_ release];
    [_authorLabel_ release];
    [_zoneLabel_ release];
    [_nameLabel_ release];
    
    [_picImageView release];
    [_titleLabel release];
    [_authorLabel release];
    [_zoneLabel release];
    [_nameLabel release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        // 图片
        self.backView_ = [[UIView alloc] init];
        self.backView_.layer.borderWidth = 1;
        self.backView_.layer.borderColor = [[UIColor colorWithWhite:0.581 alpha:1.000] CGColor];
        [self.contentView addSubview:self.backView_];
        [_backView_ release];
        
        self.picImageView = [[UIImageView alloc] init];
        [self.backView_ addSubview:self.picImageView];
        [_picImageView release];
        
        // 标题
        self.titleLabel_ = [[UILabel alloc] init];
        self.titleLabel_.text = @"名字:";
        self.titleLabel_.font = [UIFont boldSystemFontOfSize:15];
        [self.contentView addSubview:self.titleLabel_];
        [_titleLabel_ release];
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.titleLabel];
        [_titleLabel release];
        
        // 作者
        self.authorLabel_ = [[UILabel alloc] init];
        self.authorLabel_.text = @"作者:";
        self.authorLabel_.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.authorLabel_];
        [_authorLabel_ release];
        
        self.authorLabel = [[UILabel alloc] init];
        self.authorLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.authorLabel];
        [_authorLabel release];
        
        // 区域
        self.zoneLabel_ = [[UILabel alloc] init];
        self.zoneLabel_.text = @"类型:";
        self.zoneLabel_.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.zoneLabel_];
        [_zoneLabel_ release];
        
        self.zoneLabel = [[UILabel alloc] init];
        self.zoneLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.zoneLabel];
        [_zoneLabel release];
        
        // 更新时间
        self.nameLabel_ = [[UILabel alloc] init];
        self.nameLabel_.text = @"最新收录:";
        self.nameLabel_.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.nameLabel_];
        [_nameLabel_ release];
        
        self.nameLabel = [[UILabel alloc] init];
        self.nameLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.nameLabel];
        [_nameLabel release];
        
    }
    return self;
}


- (void)layoutSubviews {
    [super layoutSubviews];
    
    // 图片
    self.backView_.frame = CGRectMake(10, 5, HEIGHT * 3 / 4, HEIGHT - 10);
    self.picImageView.frame = CGRectMake(2, 2, self.backView_.frame.size.width - 4, self.backView_.frame.size.height - 4);
    
    // 名字
    self.titleLabel_.frame = CGRectMake(self.backView_.frame.origin.x + self.backView_.frame.size.width + 5, 10, 40, 20);
    self.titleLabel.frame = CGRectMake(self.titleLabel_.frame.origin.x + self.titleLabel_.frame.size.width, 10, 125 * SWIDTH / 320, 20);
   
    // 作者(尺寸改动过)
    self.authorLabel_.frame = CGRectMake(self.titleLabel_.frame.origin.x, self.titleLabel_.frame.origin.y + 20 *  SWIDTH / 320, 30, 20);
    self.authorLabel.frame = CGRectMake(self.authorLabel_.frame.origin.x + self.authorLabel_.frame.size.width, self.authorLabel_.frame.origin.y, 100 * SWIDTH / 320, 20);
    
    // 区域
    self.zoneLabel_.frame = CGRectMake(self.authorLabel_.frame.origin.x, self.authorLabel_.frame.origin.y + self.authorLabel_.frame.size.height , 30, 20);
    self.zoneLabel.frame = CGRectMake(self.zoneLabel_.frame.origin.x + self.zoneLabel_.frame.size.width, self.zoneLabel_.frame.origin.y, 100 * SWIDTH / 320, 20);
    
    // 最新收录
    self.nameLabel_.frame = CGRectMake(self.zoneLabel_.frame.origin.x , self.zoneLabel_.frame.origin.y + self.zoneLabel_.frame.size.height, 55, 20);
    self.nameLabel.frame = CGRectMake(self.nameLabel_.frame.origin.x + self.nameLabel_.frame.size.width, self.nameLabel_.frame.origin.y, 60 * SWIDTH / 320, 20);
}








/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
